package com.lagou.edu.listener;

import com.lagou.edu.factory.AnnotationBeanFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class MyServletContextListener implements ServletContextListener {
    

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("---- Servlet Context init ----");
        // 启动BeanFactory
        AnnotationBeanFactory beanFactory = new AnnotationBeanFactory("com.lagou.edu");
        servletContextEvent.getServletContext().setAttribute("beanFactory", beanFactory);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }

}
